package com.tuyan.aixiang.activity.channel;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;

import com.tuyan.aixiang.R;
import com.tuyan.aixiang.activity.login.LoginActivity;
import com.tuyan.aixiang.enums.LaunchMode;
import com.tuyan.aixiang.util.ToastUtil;

import java.util.Date;

import androidx.appcompat.app.AppCompatActivity;

/**
 * 选择用户
 */
public class ChannelActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_channel);
        Intent intent = new Intent(this, LoginActivity.class);

        findViewById(R.id.iv_personal).setOnClickListener(v -> {
//            AppData.setLanuchMode(LaunchMode.CONSUMER.getValue());
            intent.putExtra("willMode", LaunchMode.CONSUMER.getValue());
            startActivity(intent);
        });
        findViewById(R.id.iv_enterprise).setOnClickListener(v -> {
//            AppData.setLanuchMode(LaunchMode.ENTERPRISE.getValue());
            intent.putExtra("willMode", LaunchMode.ENTERPRISE.getValue());
            startActivity(intent);
        });
    }
    long lastBack = 0;

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
            long nowTimestamp = new Date().getTime();
            if (nowTimestamp - lastBack < 3000) {
                finish();
            } else {
                ToastUtil.makeShort("再次点击退出");
                lastBack = nowTimestamp;
            }
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}